<?php if (empty($this->data)) : ?>
    <div class="fail-flash">No record found.</div>
<? else : // ถ้ามีข้อมูล ?>
<?php $paginator->options(array('update' => 'divPopUpProductPaginate', 'indicator' => 'indicator')); ?>
<?php echo $this->element('dataCaptionLimit', array('update' => 'divPopUpProductPaginate', 'action' => 'popup_paginate')); ?>
<?php $cur = $paginator->counter(array('format' => '%start%')); ?>
        <table class="data">
            <thead>
                <tr>
                    <th class="no"><?php echo $paginator->sort('No', 'id'); ?></th>
                    <th width="130px"><?php echo $paginator->sort('Part no.', 'Product.part_no'); ?></th>
                    <th><?php echo $paginator->sort('Vendor', 'Supplier.name'); ?></th>
                    <th><?php echo $paginator->sort('Brand', 'Brand.name'); ?></th>
                    <th><?php echo $paginator->sort('Category', 'Category.name'); ?></th>
                    <th><?php echo $paginator->sort('Model', 'Product.model'); ?></th>
                    <th><?php echo $paginator->sort('title', 'Product.title'); ?></th>
                    <th><?php echo $paginator->sort('Current Stock', 'Product.current_stock'); ?></th>
                    <th class="action"></th>
                </tr>
            </thead>
            <tbody id="tbodyPartNo">
        <?php foreach ($this->data as $key => $data): ?>
        <?php
            $tableCell = array();
            $tableCell[] = $cur++;
            $tableCell[] = $html->link($data['Product']['part_no'], 'view/' . $data['Product']['id'], array('target' => '_blank'));
            $tableCell[] = $html->tag('span', $data['Supplier']['name']);
            $tableCell[] = $html->tag('span', $data['Brand']['name']);
            $tableCell[] = $html->tag('span', $data['Category']['name']);
            $tableCell[] = $html->tag('span', $data['Product']['model']);
            $tableCell[] = $html->tag('span', $data['Product']['title']);
            $tableCell[] = $html->tag('span', $data['Product']['current_stock']);
            $tableCell[] = $html->link($html->image('icon/edit.png'), '#', array('title' => 'Select'), null, false);
            echo $html->tableCells($tableCell, array('class' => 'odd-cell'), array('class' => 'even-cell'));
        ?>
        <?php endforeach; ?>
        </tbody>
    </table>

<?php echo $this->element('paging'); ?>
<? endif; ?>
<script type="text/javascript">
    $j(function() {
        $j('#tbodyPartNo a[title=Select]').bind('click', function() {
            var partNo = $j('td:nth-child(2) a', $j(this).parents('tr')).html();
            popup_click(partNo);
        });
    });
</script>